<?php


namespace App\Models;


class Guide extends Model
{
    protected $table = 'guides';


    // ============= scope ==========

    // ============= relations ==========
    public function cover()
    {
        return $this->belongsTo(Attachment::class, 'cover');
    }

    // ============= field ==========
    public function setName($name)
    {
        $this->name = $name;
    }

    public function getName()
    {
        return $this->name;
    }

    public function setCover($cover)
    {
        $this->cover = $cover;
    }

    public function setLevel($level)
    {
        $this->level = $level;
    }

    public function getLevel()
    {
        return $this->level;
    }

    public function getPublished()
    {
        return $this->is_published;
    }

    public function setPublished($status)
    {
        $this->is_published = $status;
    }

    public function setMetadata($metadata)
    {
        $this->metadata = json_encode($metadata);
    }

    public function getMetadata()
    {
        return json_decode($this->metadata, true);
    }
}